package com.duartepeixinho.P3D.Core.Geom 
{
	import com.duartepeixinho.P3D.Core.Math.Vector3;
	import com.duartepeixinho.P3D.Materials.Materials;
	import com.duartepeixinho.P3D.Objects.DisplayObject3D;
	/**
	 * P3D
	 * @version 0.1
	 * @author Duarte Peixinho
	 */
	public class Face3
	{
		
		/**
		 * Public Vars
		 */
		public var a:uint;
		public var b:uint;
		public var c:uint;
		public var normal:Vector3;
		public var material:Materials;
		public var do3d:DisplayObject3D;
		
		// SORTING
		public var depth:Number=0;
		
		/**
		 * Face3
		 * @param	a		uint
		 * @param	b		uint
		 * @param	c		uint
		 * @param	normal	Vector3
		 * @param	color	uint
		 */
		public function Face3(do3d:DisplayObject3D, a:Number, b:Number, c:Number, normal:Vector3, material:Materials) 
		{
			this.do3d = do3d;
			this.a = a;
			this.b = b;
			this.c = c;
			if (normal)
				this.normal = normal;
			else this.normal = new Vector3();
			this.material = material;
			
		}
		
		/**
		 * toString
		 * @return			String
		 */
		public function toString():String {
			
			return 'Face3( ' + this.a + ', ' + this.b + ', ' + this.c + ' )';
			
		}
		
		// SORTING
		public function zDepth(vertices:Array):void {
			depth = (vertices[a].z + vertices[b].z + vertices[c].z) / 0.333333;			
		}
		
	}

}